package com.cloud.code.牛客网;

import java.util.*;

/**
 * HJ23 删除字符串中出现次数最少的字符
 * <p>
 * 实现删除字符串中出现次数最少的字符，若出现次数最少的字符有多个，则把出现次数最少的字符都删除。输出删除这些单词后的字符串，字符串中其它字符保持原来的顺序。
 * <p>
 * 数据范围：输入的字符串长度满足 1 \le n \le 20 \1≤n≤20  ，保证输入的字符串中仅出现小写字母
 */
public class Test8 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Map<Character, Integer> map = new HashMap<>();
        while (scanner.hasNext()) {
            String line = scanner.nextLine();
            char[] chars = line.toCharArray();
            for (int i = 0; i < chars.length; i++) {
                Integer integer = map.get(chars[i]);
                if (integer == null) {
                    map.put(chars[i], new Integer(0));
                } else {
                    int i1 = integer + 1;
                    map.put(chars[i], i1);
                }

            }


            Collection<Integer> values = map.values();

            Integer min = Collections.min(values);
            Set<Map.Entry<Character, Integer>> entries = map.entrySet();

            for (Map.Entry<Character, Integer> entry : entries) {
                if (entry.getValue().equals(min)) {
                    line = line.replace(String.valueOf(entry.getKey()), "");
                }
            }

            System.out.println(line);

        }


    }
}
